<!--
* description: 员工信息（含输入框）
* author: dxuem
* createdDate: 2019-12-23
-->
<template>
  <section class="crmCustName">
    <el-col :span="span">
      <lableName
      :style="span==12?'width:14%':''" 
        :validrule="validrule"
        :curLabelName="curLabelName"
        :isShowLabel="isShowLabel"
        :isRequire="isRequire"
      ></lableName>
      <el-input
        :style="setInputWidth(span)"
        placeholder="请选择"
        v-model="modelText"
        :disabled="disabled"
        size="small"
        suffix-icon="el-icon-menu"
        @clear="clearCode"
        clearable
        @blur="sendCode"
        @focus="getFocusCode"
      ></el-input>
      <validateFormate :curLabelName="curLabelName"></validateFormate>
    </el-col>
    <crmEmpInfo
      :popupsVisible="curPopupsVisible"
      :codeField="codeField"
      :textField="textField"
      :comType="comType"
      :valueObject="curValueObject"
      :popupsKey="popupsKey"
      :code="modelCode"
      :text="modelText"
      :key="curPopupsKey"
      :isMul="isMul"
      @changeCode="getComponentCode1"
    ></crmEmpInfo>
  </section>
</template>
<script>
import { searchInputMixins } from "@/components/mixins/searchInputMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
export default {
  // 组件混入对象
  mixins: [searchInputMixins, valueObjectMixins],
  components: {
    crmEmpInfo:()=>import("@/components/crm/crmEjectWindows/crmEmpInfo/crmEmpInfo"),
    lableName: () => import("@/components/lableName"), //标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate"), //校验提示样式组件
  },
  props: {
    isMul: { type: Boolean, default: false }
  },
  data() {
    return {
      curLabelName: this.labelName === "" ? "员工信息选择" : this.labelName
    };
  },
  methods: {
    // 重写显示时执行事件,使用场景：父页面上组件和弹窗联动
    onShow() {
      debugger;
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      if (
        parent.formField &&
        parent.formField.custClassCode &&
        parent.formField.custClassCode !== ""
      ) {
        //赋值
        this.curValueObject.custClassCode = parent.formField.custClassCode;
        this.curPopupsKey = this.codeField + this.$utils.generateId();
      }
    },
    // 给父页面其他组件赋值
    getComponentCode1(
      code,
      text,
      codeField,
      comType,
      popupsKey,
      textField,
      otherField,
      selectData
    ) {
      this.getComponentCode(
        code,
        text,
        codeField,
        comType,
        popupsKey,
        textField,
        otherField,
        selectData
      );
      var parent = this.$utils.getHasFormFieldParentComponent(this);
      let results = selectData[0];
      for (let key in parent.formField) {
        if (results.hasOwnProperty(key)) {
          parent.formField[key] = results[key];
        }
      }
      this.$emit("emitCode", selectData);
    },
    setInputWidth(span) {
      switch (span) {
        case 6:
          return "";
        case 12:
          return "width:85%;line-height: 38px;";
      }
    }
  }
};
</script>
